﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace IEWebSite.Pages.Intranet
{
    public partial class Laboratoare : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (SqlConnection conn = Utils.GetSqlConnection()) 
            {
                if(conn.State!=System.Data.ConnectionState.Open)
                {
                    conn.Open();

                }
                SqlCommand s = new SqlCommand("Select NrCalc from Laborator where IDLaborator=@IdLaborator", conn);
                SqlParameter p = new SqlParameter("@IdLaborator", rcbLab.SelectedValue);
                s.Parameters.Add(p);
                var rez=s.ExecuteScalar();
                if (rez != null)
                {
                    if (rez != DBNull.Value)
                        txtNrCalc.Text = rez.ToString();
                }

            }
           
           
        }

        protected void rcb_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            using (SqlConnection conn = Utils.GetSqlConnection())
            {
                if (conn.State != System.Data.ConnectionState.Open)
                {
                    conn.Open();

                }
                SqlCommand s = new SqlCommand("Select NrCalc from Laborator where IDLaborator=@IdLaborator", conn);
                SqlParameter p = new SqlParameter("@IdLaborator", rcbLab.SelectedValue);
                s.Parameters.Add(p);
                var rez = s.ExecuteScalar();
                if (rez != null)
                {
                    if (rez != DBNull.Value)
                        txtNrCalc.Text = rez.ToString();
                }

            }
        }

        
    }
}
